package com.example.terminal.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.terminal.R;
import com.example.terminal.base.BaseRecyclerAdapter;
import com.example.terminal.base.BaseViewHolder;
import com.example.terminal.bean.DeviceListBean;
import com.example.terminal.bean.OutboundListBean;

import java.util.List;

public class DeviceListAdapter extends BaseRecyclerAdapter<DeviceListBean.RowsBean> {
    public DeviceListAdapter(Context mContext, List<DeviceListBean.RowsBean> mList) {
        super(mContext, mList);
    }

    @Override
    public int setContentView() {
        return R.layout.device_list_adapter_layout;
    }

    @Override
    protected void bindData(BaseViewHolder holder, DeviceListBean.RowsBean data, int position) {
        LinearLayout mLlContainerItem = holder.findViewById(R.id.mLlContainerItem);
        ImageView mIvSelected = holder.findViewById(R.id.mIvSelected);
        TextView mTv_Position = holder.findViewById(R.id.mTv_Position);//序号
        TextView mTv_DeviceName = holder.findViewById(R.id.mTv_DeviceName);//设备名称
        TextView mTv_DeviceModel = holder.findViewById(R.id.mTv_DeviceModel);//设备型号
        TextView mTv_DeviceType = holder.findViewById(R.id.mTv_DeviceType);//设备类型
        TextView mTv_DeviceSupplier = holder.findViewById(R.id.mTv_DeviceSupplier);//供应商
        TextView mTv_DeviceInventory = holder.findViewById(R.id.mTv_DeviceInventory);//库存

        mTv_Position.setText(String.valueOf(position + 1));

        mTv_DeviceName.setText("设备名称: " + data.getDeviceName());
        mTv_DeviceModel.setText("设备型号: " + data.getDeviceType());
        mTv_DeviceType.setText("设备类型: " + data.getDeviceLeixin());
        mTv_DeviceSupplier.setText("供应商: " + data.getCompany());
        mTv_DeviceInventory.setText("库存:   " + String.valueOf(data.getResidueNum()));

        mIvSelected.setImageDrawable(mContext.getDrawable(data.isSelected() ? R.mipmap.check_item_sel :R.mipmap.check_item));

        setOnItemClickListener(mLlContainerItem, position);
    }
}
